import { h, type Component } from "vue";
import { NIcon } from "naive-ui";
import type { Icon5Name, IconAntDName, IconFluentName } from "@/typings/icon";
import { icon5, iconAntD, iconFluent } from "@/typings/icon";

/** 根据 icon 组件组渲染 icon */
export const RenderIcon = (icon: Component) => {
  return () => {
    return h(NIcon, null, {
      default: () => h(icon),
    });
  };
};

/** 根据 icon name string 渲染组件 */
export const RenderIcon5ByName = (iconName: Icon5Name) => {
  return () => {
    return h(NIcon, null, {
      default: () => h(icon5[iconName]),
    });
  };
};

/** 根据 icon name string 渲染组件 */
export const RenderIconAntDByName = (iconName: IconAntDName) => {
  return () => {
    return h(NIcon, null, {
      default: () => h(iconAntD[iconName]),
    });
  };
};

/** 根据 icon name string 渲染组件 */
export const RenderIconFluentByName = (iconName: IconFluentName) => {
  return () => {
    return h(NIcon, null, {
      default: () => h(iconFluent[iconName]),
    });
  };
};
